package com.mengtian_tech.smart_lab.service.impl.system;

import java.util.List;

import javax.transaction.Transactional;

import org.jeecgframework.core.common.hibernate.qbc.CriteriaQuery;
import org.jeecgframework.core.common.model.json.DataGridReturn;
import org.jeecgframework.web.system.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.mengtian_tech.smart_lab.entity.system.SystemConfig;
import com.mengtian_tech.smart_lab.entity.system.SystemConfigNames;
import com.mengtian_tech.smart_lab.service.system.SystemConfigService;

@Service
@Transactional
public class SystemConfigServiceImpl implements SystemConfigService{

	@Autowired
	SystemService systemService;
	
	@Override
	public void save(SystemConfig config) {
		systemService.save(config);
	}

	@Override
	public List<SystemConfig> findList() {
		return systemService.findByQueryString("from SystemConfig ");
	}

	@Override
	public SystemConfig findByName(SystemConfigNames name) {
		List<SystemConfig> list = 
				systemService.findByQueryString(
						" from SystemConfig a where a.configName = ? ",
						new Object[]{name.name()});
		
		if(list.size() > 0){
			return list.get(0);
		}else{
			return null;
		} 
	}

	@Override
	public DataGridReturn getDataGridReturn(CriteriaQuery cq, boolean b) {
		return systemService.getDataGridReturn(cq, b);
	}

	@Override
	public SystemConfig get(String id) {
		return systemService.get(SystemConfig.class, id);
	}

}
